package com.sync.data.ievent.repository;

import com.sync.data.ievent.entity.IeventSysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.Set;


@Repository
public interface IeventSysUserRepository extends JpaRepository<IeventSysUser, String>, JpaSpecificationExecutor<IeventSysUser> {

    @Query("SELECT u.workNo FROM IeventSysUser u")
    Set<String> findAllWorkNoSet();

    boolean existsByWorkNo(String workNo);

    @Query("SELECT COUNT(DISTINCT u.workNo) FROM IeventSysUser u")
    int countDistinctWorkNos();

    Optional<IeventSysUser> findByWorkNo(String workNo);

    Optional<IeventSysUser> findByUsername(String username);

    List<IeventSysUser> findByWorkNoIn(List<String> workNos);
}
